package com.xiliu.rocketmq;

import org.apache.rocketmq.client.exception.MQClientException;
import org.apache.rocketmq.client.producer.DefaultMQProducer;
import org.apache.rocketmq.client.producer.SendResult;
import org.apache.rocketmq.common.message.Message;
import org.apache.rocketmq.remoting.common.RemotingHelper;

/**
 * @author xiliu
 * @description
 * @date 2022/3/3
 */
public class SyncProducerFilterDemo {

    public static void main(String[] args) throws Exception{
        DefaultMQProducer producer = new DefaultMQProducer("xiliu_producer_group");
        producer.setNamesrvAddr("42.194.222.32:9876");
        producer.start();

        String msgStr = "我是希留001";
        Message message = new Message("broker-a","xiliu_tag",msgStr.getBytes(RemotingHelper.DEFAULT_CHARSET));
        message.putUserProperty("age", "21");
        message.putUserProperty("sex", "男");
        // 发送消息
        SendResult sendResult = producer.send(message,10000);

        System.out.println(sendResult);
        producer.shutdown();
    }
}
